from wand.image import Image
import os


def convert_jp2_to_jpg():
    orignal_path = 'H:\\古籍\\4集'

    for filepath, dirnames, filenames in os.walk(orignal_path):
        for filename in dirnames:
            n = filepath.split('\\')
            if len(n) > 3:
                filePath = os.path.join(filepath, filename)
                if len(os.listdir(filePath)) == 0 and '空' not in filePath:
                    print(filePath)
                    newfilePath = os.path.join(filepath, filename + ' 空')
                    os.rename(filePath,newfilePath)


convert_jp2_to_jpg()
